package s15.ch18.homework;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class MyCurrentDate implements Runnable {
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MMM/dd HH:mm:ss");
	private String datka;
	private Thread thread;

	public String getDatka() {
		return datka;
	}

	public void setDatka(String datka) {
		this.datka = datka;
	}

	public MyCurrentDate(String datka) {
		this.setDatka(datka);
		this.setThread(new Thread(this, getDatka()));
	}

	public void run() {

		for (Integer i = 0; i < 10; i++) {
			try {
				Calendar currentDate = Calendar.getInstance();
				String dateNow = formatter.format(currentDate.getTime());
				System.out.println(getDatka() + " :=>  " + dateNow);
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	public Thread getThread() {
		return thread;
	}

	public void setThread(Thread thread) {
		this.thread = thread;
	}

	public void start() {
		getThread().start();
	}

}
